<?php
/**

 */
class IndexController extends App_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    { 
    	if (!empty($this->view->user_id)) $this->_redirect("/client");	
    	
    	$model_service = new Model_Service();
    	$all_services = $model_service->getAllService();  			
		$this->view->all_services=$all_services;		
    	$all_groups = $model_service->getAllGroup();  			
		$this->view->all_groups=$all_groups;	
    }
    
    
    public function googleAction()
    { 
		$request = $this->getRequest();

		$form = new Form_ClientLogin();
		$form->setAction('/login/client');
		$this->view->form = $form;
    	
		//check IP		
		$ip=Model_ActionLog::getIp();
		if (1==0){
			$this->view->formError = 'IP address not allowed.';				
		}else{
    
	    	$return_url = "login/google-openid";
	    	$association_handle = App_GoogleOpenID::getAssociationHandle();
	    	
	    	
	    	$googleLogin = App_GoogleOpenID::createRequest($return_url, $association_handle, true);
	    	$googleLogin->redirect();
	    	
	    	exit("");
		}
    }

}

